package com.tengniu.api.controller.buss;

import cn.binarywang.wx.miniapp.api.WxMaService;
import com.tengniu.biz.bo.BannerResultBo;
import com.tengniu.api.service.BannerApiService;
import com.tengniu.common.core.controller.BaseController;
import com.tengniu.common.core.domain.AjaxResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * 轮播图相关
 */
@RestController
@RequestMapping("/api/banner")
@Slf4j
public class BannerController extends BaseController {

    @Resource
    private BannerApiService bannerApiService;

    @Resource
    private WxMaService wxMaService;

    /**
     * 小程序获取轮播图
     */
    @GetMapping("/list")
    public AjaxResult banners() {
        startPage(false);
        List<BannerResultBo> banners = bannerApiService.banners();
        return AjaxResult.success(banners);
    }

    /**
     * 小程序根据类型获取轮播图
     */
    @GetMapping("/listByType/{type}")
    public AjaxResult bannersByType(@PathVariable Integer type) {
        startPage(false);
        List<BannerResultBo> banners = bannerApiService.bannersByType(type);
        return AjaxResult.success(banners);
    }

}
